<!DOCTYPE HTML>
<?php 
require_once'config.php';
require_once'functions.php';
?>
<html>
<head>
<style>#true-falseQuestion, #multiple-choiceQuestion, #checkboxQuestion
{
	display:none;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>
<body>
<?php
$getQuestion = getQuestion($currentQuestion);
$currentQuestion = $num;
/*if(isset($_POST['checkAnswer']))
{
	$num = $_POST['num'];
	$selectedAnswer = $_POST['questionOptions'];
	$correctAnswer = $getQuestion['correctAnswer'];
	if ($selectedAnswer == $correctAnswer)
	{
		$feedbackStatus = "<span class='green'> correct.</span>";
		
		$score = ($_POST['score'] + 1);
		$_SESSION['score'] = $score ;

	}
	else
	{
		$feedbackStatus = "<span class='red'> incorrect.</span>";
		$score = ($_POST['score']);
		$_SESSION['score'] = $score ;
	}
	}*/
if (isset($_POST['getNext']))
{
	$num = $_POST['num'];
	$score = $_POST['score'];
	$_SESSION['score'] = $_POST['score']; 
	$getQuestion = getQuestion($currentQuestion);
} 
if ($getQuestion['type'] == "multiple-choice")
{
	$displayMC = "block";
	}
if ($getQuestion['type'] == "checkbox")
{
	$displayCB = "block"; 
	}
if ($getQuestion['type'] == "true-false")
{
	$displayTF = "block"; 
	}
?>
 <?php  if (!isset($_POST['checkAnswer'])) //not started yet
{ 
?>
<form id="question" action"feedback.php" method="post" >
    <h2>Question
      <?php echo $getQuestion['questionID']; ?>
    </h2>
    <div id='resource'>
      <?php echo $getQuestion['resource'] ?>
    </div>
    <div class="q-stem">
      <p id="itemStem">
        <?php echo $getQuestion['stem'] ?>
      </p>
    </div>
    <div id="multiple-choiceQuestion" style="display:<?php echo $displayMC ?>">
      <div>
        <input name="questionOptions" id="radio1" type="radio" value="<?php echo $getQuestion['option1'] ?>">
        <label id="label1" for="radio1">
          <?php echo $getQuestion['option1'];?>
        </label>
      </div>
      <div>
        <input name="questionOptions" id="radio2" type="radio" value="<?php echo $getQuestion['option2'] ?>">
        <label id="option2" for="radio2">
          <?php echo $getQuestion['option2'] ?>
        </label>
      </div>
      <div>
        <input name="questionOptions" id="radio3" type="radio" value="<?php echo $getQuestion['option3'] ?>">
        <label id="option3" for="radio3">
          <?php echo $getQuestion['option3'] ?>
        </label>
      </div>
      <div>
        <input name="questionOptions" id="radio4" type="radio" value="<?php echo $getQuestion['option4'] ?>">
        <label id="option4" for="radio4">
          <?php echo $getQuestion['option4'] ?>
        </label>
      </div>
    </div>
    <div id="true-falseQuestion" style="display:<?php echo $displayTF ?>">
      <div>
        <input name="questionOptions" id="radio1" type="radio" value="<?php echo $getQuestion['option1'] ?>">
        <label id="label1" for="radio1">
          <?php echo $getQuestion['option1'];?>
        </label>
      </div>
      <div>
        <input name="questionOptions" id="radio2" type="radio" value="<?php echo $getQuestion['option2'] ?>">
        <label id="option2" for="radio2">
          <?php echo $getQuestion['option2'] ?>
        </label>
      </div>
    </div>
    <div id="checkboxQuestion" style="display:<?php echo $displayCB ?>">
      <div>
        <input name="questionOptions" id="checkbox1" type="checkbox" value="<?php echo $getQuestion['option1'] ?>">
        <label id="label1" for="checkbox1">
          <?php echo $getQuestion['option1'];?>
        </label>
      </div>
      <div>
        <input name="questionOptions" id="checkbox2" type="checkbox" value="<?php echo $getQuestion['option2'] ?>">
        <label id="option2" for="checkbox2">
          <?php echo $getQuestion['option2'] ?>
        </label>
      </div>
      <div>
        <input name="questionOptions" id="checkbox3" type="checkbox" value="<?php echo $getQuestion['option3'] ?>">
        <label id="option3" for="checkbox3">
          <?php echo $getQuestion['option3'] ?>
        </label>
      </div>
      <div>
        <input name="questionOptions" id="checkbox4" type="checkbox" value="<?php echo $getQuestion['option4'] ?>">
        <label id="option4" for="checkbox4">
          <?php echo $getQuestion['option4'] ?>
        </label>
      </div>
    </div>
	<input type="hidden" name="num" value="<?php echo $num ?>" />
    <input type="hidden" name="score" value="<?php echo $score ?>" />
    <input type="hidden" name="checkAnswer" value="TRUE" />
    <input type="submit" id="checkAnswerBtn" name="checkAnswerBtn" value="Check Answer" class="btn" />
	</form>
<?php /*} elseif (isset($_POST['checkAnswer']))
{*/
?>
    <form id="feedback" method="post">
    <p>You answered:
		<?php echo($_POST['questionOptions']);?>
    </p>
    <p>The correct answer was 
		<?php echo $getQuestion['correctAnswer'];?>. 
        You were <?php echo $feedbackStatus; ?>
	</p>
    <input type="hidden" name="num" value="<?php echo $num + 1 ?>" />
    <input type="hidden" name="score" value="<?php echo $_SESSION['score'] ; ?>" />
    <input type="hidden" name="getNext" value="TRUE" />
    <input type="submit" id="submit" name="next" value="Next Question" class="btn" />
<?php 
}
if($currentQuestion == 10)
{ 
	$last = true; 
	$_SESSION['finished'] = 'yes';
?>
     <input type="hidden" name="num" value="<?php echo $num + 1 ?>" />
     <input type="hidden" name="score" value="<?php echo $_SESSION['score'] ; ?>" />
     <input type="submit" id="results" name="results" value="Get Results" class="btn" />
	</form>
<?php } ?>
          <p class='smiling'>Score:
        <?php echo $score ?>
      </p>
      <p class='smiling'>Num:
        <?php echo $num ?>
      </p>
        </p>
           <p class='smiling'>Current Question:
        <?php echo ($currentQuestion)?>
      </p>
</body>
</html>